export const isEmpty = (value) => {
    switch (typeof value) {
        case 'undefined':
            return true
        case 'string':
            if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true
            break
        case 'boolean':
            if (!value) return true
            break
        case 'number':
            if (value === 0 || isNaN(value)) return true
            break
        case 'object':
            if (value === null || value.length === 0) return true
            for (const i in value) {
                return false
            }
            return true
    }
    return false
}


//密码验证
// const REGEXP_PWD =
// 	/^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)]|[()])+$)(?!^.*[\u4E00-\u9FA5].*$)([^(0-9a-zA-Z)]|[()]|[a-z]|[A-Z]|[0-9]){6,18}$/;
export const REGEXP_PWD =
    /^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)]|[()])+$)(?!^.*[\u4E00-\u9FA5].*$)([^(0-9a-zA-Z)]|[()]|[a-z]|[A-Z]|[0-9]){6,18}$/;

export const checkPassword = (value) => {

    return REGEXP_PWD.test(value)
}


export const PHONE_REG = /^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/;

//验证是否是手机号
export function isPhoneNumber(str) {
	if (!PHONE_REG.test(str)) {
		return false
	} else {
		return true
	}
}
// export const validator = (rule, value, data, callback) => {
//     const errorMsg = "密码格式应为6-18位数字、字母、符号的任意两种组合";
//     if (!value) {
//         callback("请输入密码");
//     } else if (value === undefined) {
//         callback();
//     } else if (value && !REGEXP_PWD.test(value)) {
//         callback(errorMsg);
//     } else {
//         callback();
//     }
// };